<!--
 * @Description: 产品报告
 * @Autor: wangwangwang
 * @Date: 2021-03-22 18:37:24
 * @LastEditors: wangwangwang
 * @LastEditTime: 2021-09-08 14:29:25
-->
<template>
  <div>
    <!-- 产品报告 -->
    <el-dialog v-dialogDrag :visible.sync="look1Type" width="880px" :close-on-click-modal="false">
      <span slot="title" class="dialog-title">产品报告</span>
      <div class="dialogOtherinfo">
        <el-table :header-cell-style="{ background: '#f3f6f9' }" :cell-style="{ borderRight: 'none' }" border stripe style="width:100%" :data="table2" tooltip-effect="dark">
          <el-table-column prop="productName" label="产品名" align="center"></el-table-column>
          <el-table-column label="自检报告" width="auto" align="center">
            <template slot-scope="scope">
              <span class="table_link" @click="look11Fun(scope.row,'出场')">出场检验编号</span>
            </template>
          </el-table-column>
          <el-table-column label="抗渗报告" width="auto" align="center">
            <template slot-scope="scope">
              <span class="table_link" @click="look11Fun(scope.row,'抗渗报告')">抗渗报告</span>
            </template>
          </el-table-column>
          <el-table-column label="第三方报告" width="auto" align="center">
            <template slot-scope="scope">
              <span class="table_link" @click="look11Fun(scope.row,'第三方')">第三方检验</span>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button class="bottom_all_two" @click="look1Type = false">关 闭</el-button>
      </span>
    </el-dialog>
    <!-- 配合比 -->
    <el-dialog :visible.sync="look2Type" width="1200px" :close-on-click-modal="false">
      <span slot="title" class="dialog-title">配合比</span>
      <div class="dialogOtherinfo">
        <el-form ref="reffromDate" :inline="true" :model="fromDate" label-width="130px">
          <el-form-item prop="enginnerrMixRatio" label-width="190px" :rules="[{required: true,message: '请输入工程配合比特殊要求',trigger: 'blur',}]">
            <span slot="label" style="font-size:18px;">工程配合比特殊要求</span>
            <el-input v-model="fromDate.enginnerrMixRatio" style="width:520px;" placeholder="请输入" clearable size="medium"></el-input>
          </el-form-item>
          <div>
            <el-form-item label="水泥原物料品牌" prop="cementBrandId" :rules="[{required: true,message: '请选择水泥原物料品牌',trigger: 'blur',}]">
              <el-select v-model="fromDate.cementBrandId" placeholder="请选择" style="width:220px">
                <el-option v-for="(item, index) in arr3_3" :key="index" :label="item.itemName" :value="item.id"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="开盘工程名称" prop="openingProjecName" :rules="[{required: true,message: '请输入开盘工程名称',trigger: 'blur',}]">
              <el-input v-model="fromDate.openingProjecName"></el-input>
            </el-form-item>
          </div>
          <el-form-item label="配合比类型">
            <el-select v-model="fromDate.type" style="width:220px" placeholder="请选择" @change="workMixRatioqueryListByGeneralFun()">
              <el-option label="通用配合比" :value="1"></el-option>
              <el-option label="专用配合比" :value="2"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="配合比名称">
            <el-select v-model="fromDate.DetailId" style="width:220px" placeholder="请选择" @change="workMixRatiogetRatioDetailFun()">
              <el-option v-for="(item, index) in arr3_5" :key="index" :label="item.name" :value="item.id"></el-option>
            </el-select>
          </el-form-item>
          <div class="form-title" style="margin-bottom:10px;">搜索历史配合比</div>
          <el-form-item label="工程名称">
            <el-select v-model="tableParam3.engineeringId" style="width:180px" placeholder="请选择">
              <el-option v-for="(item, index) in engineeringIdList" :key="index" :label="item.engineeringName" :value="item.engineeringId"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="浇筑部位">
            <el-input v-model="tableParam3.structuralParts" style="width:180px" placeholder="请输入" clearable></el-input>
          </el-form-item>
          <el-form-item label="产品名">
            <el-input v-model="tableParam3.productName" style="width:180px" placeholder="请输入" clearable></el-input>
          </el-form-item>
          <el-button icon="el-icon-search" size="medium" class="bottom_all" @click="(tableParam3.page = 1), gettableData()">查 询</el-button>
          <el-table ref="singleTable" :header-cell-style="{ background: '#f3f6f9' }" :cell-style="{ borderRight: 'none' }" border stripe style="width:100%" :data="table3" tooltip-effect="dark" highlight-current-row @current-change="currentChange3">
            <el-table-column type="selection" width="55">
              <template slot-scope="scope">
                <el-radio v-model="yiFenPeiRadio" :label="scope.row.id">{{""}}</el-radio>
              </template>
            </el-table-column>
            <el-table-column prop="orderNo" label="订单编号" width="auto" align="center"></el-table-column>
            <el-table-column prop="engineeringName" label="工程名称" width="120" align="center"></el-table-column>
            <el-table-column prop="place" label="工程地址" width="auto" align="center"></el-table-column>
            <el-table-column prop="structuralParts" label="浇筑部位" width="120" align="center"></el-table-column>
            <el-table-column prop="productName" label="产品名" width="auto" align="center"></el-table-column>
            <el-table-column prop="mixRatioNumber" label="交工配合比编号" width="120" align="center"></el-table-column>
            <el-table-column prop="reportTime" label="报告时间" width="auto" align="center"></el-table-column>
            <el-table-column prop="pouringTime" label="浇筑时间" width="auto" align="center"></el-table-column>
          </el-table>
          <el-pagination :current-page.sync="tableParam3.page" :page-size="tableParam3.pageSize" layout="total, prev, pager, next, jumper" :total="tableParam3.total" @current-change="gettableData()"></el-pagination>
          <div class="form-title" style="margin-bottom:10px;">配合比参数</div>
          <el-form-item prop="unitWeight" :rules="[{required: true,message: '请输入容重',trigger: 'blur',}]">
            <span slot="label" style="color: #ff0000">容重kg/m³</span>
            <el-input v-model="fromDate.unitWeight" type="Number" placeholder="请输入" clearable @change="calculatorFun(true)"></el-input>
          </el-form-item>
          <el-form-item prop="totalPlasticMaterial" :rules="[{required: true,message: '请输入胶材总量',trigger: 'blur',}]">
            <span slot="label" style="color: #ff0000">胶材总量</span>
            <el-input v-model="fromDate.totalPlasticMaterial" type="Number" placeholder="请输入" clearable @change="calculatorFun(true)"></el-input>
          </el-form-item>
          <el-form-item prop="waterBinderRatio" :rules="[{required: true,message: '请输入水胶比',trigger: 'blur',}]">
            <span slot="label" style="color: #ff0000">水胶比</span>
            <el-input v-model="fromDate.waterBinderRatio" type="Number" placeholder="请输入" clearable @change="calculatorFun(true)"></el-input>
          </el-form-item>
          <el-form-item prop="sandRatio" :rules="[{required: true,message: '请输入砂率',trigger: 'blur',}]">
            <span slot="label" style="color: #ff0000">砂率%</span>
            <el-input v-model="fromDate.sandRatio" type="Number" placeholder="请输入" clearable @change="calculatorFun(true)"></el-input>
          </el-form-item>
          <el-form-item prop="slump" :rules="[{required: true,message: '请输入坍落度',trigger: 'blur',}]">
            <span slot="label" style="color: #ff0000">坍落度(mm)</span>
            <el-input v-model="fromDate.slump" placeholder="请输入" clearable></el-input>
          </el-form-item>
          <el-form-item prop="temperature" :rules="[{required: true,message: '请输入选用温度',trigger: 'blur',}]">
            <span slot="label" style="color: #ff0000">选用温度(℃)</span>
            <el-input v-model="fromDate.temperature" placeholder="请输入" clearable></el-input>
          </el-form-item>
          <el-form-item v-if="mixRatioNumberType">
            <span slot="label" style="color: #ff0000">配合比编号</span>
            <el-input v-model="fromDate.mixRatioNumber" type="Number" placeholder="请输入" clearable disabled></el-input>
          </el-form-item>
          <div style="padding-bottom: 10px;">
            <el-button size="mini" class="bottom_all" style="margin-left: 0;" @click="addItem()">
              <i class="icon iconfont iconicon_button_add" style="font-size: 12px;"></i>
              添加
            </el-button>
          </div>
          <el-table :header-cell-style="{ background: '#f3f6f9' }" :cell-style="{ borderRight: 'none' }" border :row-class-name="tableRowClassName" style="width:100%" :data="toViewList" tooltip-effect="dark" class="FZYtable">
            <el-table-column label="原物料" align="center" prop="orderNo" width="140">
              <template slot-scope="scope">
                <el-select v-model="scope.row.rawId" placeholder="请选择" style="width: 100%;" @change="changeItem(scope.row,'rawId')">
                  <el-option v-for="(item, index) in rawIdArry" :key="index" :label="item.name" :value="item.id"></el-option>
                </el-select>
              </template>
            </el-table-column>
            <el-table-column label="规格型号" align="center" prop="orderNo" width="140">
              <template slot-scope="scope">
                <el-select v-model="scope.row.specificationId" placeholder="请选择" style="width: 100%;" clearable @change="changeItem(scope.row,'specificationId')">
                  <el-option v-for="(item, index) in specificationIdArry" :key="index" :label="item.itemName" :value="item.id"></el-option>
                </el-select>
              </template>
            </el-table-column>
            <el-table-column label="公式参数类型" align="center" prop="orderNo" width="140">
              <template slot-scope="scope">
                <el-select v-model="scope.row.formulaParametersId" placeholder="请选择" style="width: 100%;" :disabled="$options.filters.filtFormula(scope.$index)" @change="changeItem(scope.row,'formulaParametersId',scope.$index)">
                  <el-option v-for="(item, index) in formulaParametersIdArry" :key="index" :label="item.name" :value="item.id" :disabled="item.type"></el-option>
                </el-select>
              </template>
            </el-table-column>
            <el-table-column label="参数类型" align="center" prop="parametersType" width="100"></el-table-column>
            <el-table-column label="参量" align="center" width="150">
              <template slot-scope="scope">
                <div style="text-align: left;">
                  <el-input-number v-model="scope.row.parameter" :controls="false" :precision="$options.filters.precision(scope.row)" style="width: 80px;" :disabled="scope.row.formulaParametersId==2" @change="calculatorFun()"></el-input-number>
                  <span v-if="scope.row.formulaParametersId !=6"> %</span><span v-else> kg/m³</span>
                </div>
              </template>
            </el-table-column>
            <el-table-column label="配合比值" align="center" width="130">
              <template slot-scope="scope">
                {{scope.row.ratioValue}} kg/m³
              </template>
            </el-table-column>
            <el-table-column label="自检报告" align="center">
              <template slot-scope="scope">
                <div v-if="scope.row.formulaParametersId !=1 && scope.row.ratioValue!=0">
                  <span v-if="scope.row.selfBarchNum" class="table_link" @click="look21Fun(scope.row,'批次检验',scope.$index)">{{scope.row.selfBarchNum}}</span>
                  <span v-else class="table_link" @click="look21Fun(scope.row,'批次检验',scope.$index)">选择</span>
                </div>
              </template>
            </el-table-column>
            <el-table-column label="原物料品牌" align="center">
              <template slot-scope="scope">
                <div v-if="scope.row.formulaParametersId !=1 && scope.row.ratioValue!=0">
                  <span v-if="scope.row.brand">{{scope.row.brand}}</span>
                  <span v-else></span>
                </div>
              </template>
            </el-table-column>
            <el-table-column label="厂家材质报告" align="center">
              <template v-if="scope.row.formulaParametersId !=1" slot-scope="scope">
                <el-upload action="/resource/resources/upload" :show-file-list="false" :before-upload="beforeUpload" :on-success="filesuccess" :headers="upheader">
                  <el-link class="table_link" :underline="false" @click="scopeIndex=1,rowIndex=scope.$index">{{scope.row.materialReportPath?'修改':'上传'}}</el-link>
                </el-upload>
                <div v-if="scope.row.materialReportPath" class="upload-item-text">
                  <a class="el-link" :href="'/file/' +scope.row.materialReportPath" download>
                    <span style="color:#3f8e4d;">{{scope.row.materialReport}}</span>
                    <i class="el-icon-download" style="padding:0 10px"></i>
                  </a>
                </div>
              </template>
            </el-table-column>
            <el-table-column label="合格证" align="center">
              <template v-if="scope.row.formulaParametersId !=1" slot-scope="scope">
                <el-upload action="/resource/resources/upload" :show-file-list="false" :before-upload="beforeUpload" :on-success="filesuccess" :headers="upheader">
                  <el-link class="table_link" :underline="false" @click="scopeIndex=2,rowIndex=scope.$index">{{scope.row.qualificationPath?'修改':'上传'}}</el-link>
                </el-upload>
                <div v-if="scope.row.qualificationPath" class="upload-item-text">
                  <a class="el-link" :href="'/file/' +scope.row.qualificationPath" download>
                    <span style="color:#3f8e4d;">{{scope.row.materialReport}}</span>
                    <i class="el-icon-download" style="padding:0 10px"></i>
                  </a>
                </div>
              </template>
            </el-table-column>
            <el-table-column label="第三方报告" align="center">
              <template slot-scope="scope">
                <div v-if="scope.row.ratioValue!=0">
                  <span v-if="scope.row.selfRipartiteNum" class="table_link" @click="look21Fun(scope.row,'第三方检验',scope.$index)">{{scope.row.selfRipartiteNum}}</span>
                  <span v-else class="table_link" @click="look21Fun(scope.row,'第三方检验',scope.$index)">选择</span>
                </div>
              </template>
            </el-table-column>
            <el-table-column label="操作" align="left" width="100">
              <template slot-scope="scope">
                <el-button v-show="$options.filters.filtDel(scope.$index)" size="mini" class="bottom_two" @click="deleteItem(scope.$index)">
                  <i class="icon iconfont iconicon_button_delete" style="font-size: 12px;"></i>
                  删除
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button class="bottom_all_two" @click="look2Type=false">取 消</el-button>
        <el-button class="bottom_all" style="margin-left: 24px;" @click="discloseupdateOneFun()">保 存</el-button>
      </span>
    </el-dialog>
    <!-- 产品名-自检报告 -->
    <el-dialog v-dialogDrag :visible.sync="look11Type" width="880px" :close-on-click-modal="false">
      <span slot="title" class="dialog-title">自检报告</span>
      <div class="dialogOtherinfo">
        <p>
          <span v-if="name == '出场'">抗压报告</span>
          <span v-if="name == '抗渗报告'">抗渗报告</span>
          <span v-if="name == '第三方'">第三方报告</span>
          <el-button v-if="name!='第三方'" size="mini" class="bottom_all" style="float: right;position: relative;top: -5px;" @click="selfreportsaveOneFun()">
            <i class="icon iconfont iconicon_button_add" style="font-size: 12px"></i>
            新增报告
          </el-button>
        </p>
        <el-table ref="table11Refs" height="300" :header-cell-style="{ background: '#f3f6f9' }" :cell-style="{ borderRight: 'none' }" border stripe style="width:100%" :data="table11" tooltip-effect="dark" highlight-current-row @selection-change="selectionChange11">
          <el-table-column type="selection" width="55">
          </el-table-column>
          <el-table-column prop="checkoutNumber" label="出场检验编号" width="auto" align="center"></el-table-column>
          <el-table-column prop="productName" label="产品名" width="260" align="center"></el-table-column>
          <el-table-column prop="engineeringName" label="工程名称" width="auto" align="center"></el-table-column>
          <el-table-column v-if="name != '第三方'" prop="" label="操作" width="120" align="center">
            <template slot-scope="scope">
              <el-link class="table_link" :underline="false" @click="modifyLookFun(scope.row)">修改</el-link>
              <el-link v-if="scope.row.checkStatus!=1&&name == '第三方'" class="table_link" :underline="false" style="color:red;" @click="delTable11Fun(scope.row)">删除</el-link>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button class="bottom_all_two" @click="look11Type = false">取 消</el-button>
        <el-button class="bottom_all" style="margin-left: 24px;" @click="planSelfsaveManyFun()">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 配合比-自检报告 -->
    <el-dialog v-dialogDrag :visible.sync="look21Type" width="880px" :close-on-click-modal="false">
      <span slot="title" class="dialog-title">自检报告</span>
      <div class="dialogOtherinfo">
        <p><span v-if="name2 == '批次检验'">选择自检报告库（3天后自动过期）</span><span v-else>选择第三方报告库（3天后自动过期）</span>
        </p>
        <el-table :header-cell-style="{ background: '#f3f6f9' }" :cell-style="{ borderRight: 'none' }" border stripe style="width:100%" :data="table21" tooltip-effect="dark" highlight-current-row @current-change="selectionChange21radioFun">
          <el-table-column width="55">
            <template slot-scope="scope">
              <el-radio v-model="selectionChange21radio" :label="scope.row.id">{{""}}</el-radio>
            </template>
          </el-table-column>
          <el-table-column prop="checkoutNumber" :label="name2 == '批次检验'?'批次检验编号':'三方报告编号'" width="auto" align="center"></el-table-column>
          <el-table-column prop="rawName" label="原物料名称" width="auto" align="center"></el-table-column>
          <el-table-column v-if="name2=='批次检验'" prop="brand" label="品牌" width="auto" align="center"></el-table-column>
          <el-table-column v-if="name2=='批次检验'" prop="specification" label="规格" width="auto" align="center"></el-table-column>
          <el-table-column v-if="name2=='批次检验'" prop="originPlace" label="产地" width="auto" align="center"></el-table-column>
          <el-table-column prop="supplierName" label="供应商" width="auto" align="center"></el-table-column>
          <el-table-column v-if="name2 == '批次检验'" prop="" label="操作" width="120" align="center">
            <template slot-scope="scope">
              <el-link class="table_link" :underline="false" @click="modifyLookFun(scope.row)">修改</el-link>
              <el-link v-if="scope.row.checkStatus!=1" class="table_link" :underline="false" style="color:red;" @click="delTable21Fun(scope.row)">删除</el-link>
            </template>
          </el-table-column>
        </el-table>
        <el-pagination :current-page.sync="tableParam21.page" :page-size="tableParam21.pageSize" layout="total, prev, pager, next, jumper" :total="tableParam21.total" @current-change="getmaintenancelist21()"></el-pagination>
        <p><span v-if="name2 == '批次检验'">批次检验列表</span><span v-else>第三方原物料检验列表</span></p>
        <el-table ref="singleTable" :header-cell-style="{ background: '#f3f6f9' }" :cell-style="{ borderRight: 'none' }" border stripe style="width:100%" :data="table22" tooltip-effect="dark" highlight-current-row>
          <el-table-column prop="checkoutNumber" :label="name2 == '批次检验'?'批次检验编号':'三方报告编号'" width="auto" align="center">
            <template slot-scope="scope">
              <span v-if="name2 == '批次检验'">{{scope.row.checkoutNumber}}</span>
              <span v-else>{{scope.row.code}}</span>
            </template>
          </el-table-column>
          <el-table-column prop="rawName" label="原物料名称" width="auto" align="center"></el-table-column>
          <el-table-column v-if="name2=='批次检验'" prop="brand" label="品牌" width="auto" align="center"></el-table-column>
          <el-table-column v-if="name2=='批次检验'" prop="specification" label="规格" width="auto" align="center"></el-table-column>
          <el-table-column v-if="name2=='批次检验'" prop="originPlace" label="产地" width="auto" align="center"></el-table-column>
          <el-table-column prop="supplierName" label="供应商" width="auto" align="center"></el-table-column>
          <el-table-column prop="" label="操作" width="120" align="center">
            <template slot-scope="scope">
              <el-link :disabled="scope.row.additionStatus != 1" class="table_link" :underline="false" @click="addtable21(scope.row,'原物料')">添加到库</el-link>
            </template>
          </el-table-column>
        </el-table>
        <el-pagination :current-page.sync="tableParam22.page" :page-size="tableParam22.pageSize" layout="total, prev, pager, next, jumper" :total="tableParam22.total" @current-change="getmaintenancelist22()"></el-pagination>
        <p><span v-if="name2 == '批次检验'">已过期自检报告库</span><span v-else>第三方已过期自检报告库</span></p>
        <el-table ref="singleTable" :header-cell-style="{ background: '#f3f6f9' }" :cell-style="{ borderRight: 'none' }" border stripe style="width:100%" :data="table23" tooltip-effect="dark" highlight-current-row>
          <el-table-column prop="checkoutNumber" :label="name2 == '批次检验'?'批次检验编号':'三方报告编号'" width="auto" align="center"></el-table-column>
          <el-table-column prop="rawName" label="原物料名称" width="auto" align="center"></el-table-column>
          <el-table-column v-if="name2=='批次检验'" prop="brand" label="品牌" width="auto" align="center"></el-table-column>
          <el-table-column v-if="name2=='批次检验'" prop="specification" label="规格" width="auto" align="center"></el-table-column>
          <el-table-column v-if="name2=='批次检验'" prop="originPlace" label="产地" width="auto" align="center"></el-table-column>
          <el-table-column prop="supplierName" label="供应商" width="auto" align="center"></el-table-column>
          <el-table-column prop="" label="操作" width="120" align="center">
            <template slot-scope="scope">
              <el-link class="table_link" :underline="false" @click="addtable21(scope.row,'已过期')">复制到库</el-link>
            </template>
          </el-table-column>
        </el-table>
        <el-pagination :current-page.sync="tableParam23.page" :page-size="tableParam23.pageSize" layout="total, prev, pager, next, jumper" :total="tableParam23.total" @current-change="getmaintenancelist23()"></el-pagination>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button class="bottom_all_two" @click="look21Type = false">取 消</el-button>
        <el-button class="bottom_all" style="margin-left: 24px;" @click="addListlist0Fun()">确 定</el-button>
      </span>
    </el-dialog>
    <!-- 产品名+配合比-自检报告-修改 -->
    <el-dialog v-dialogDrag :visible.sync="look11ModifyType" width="880px" :close-on-click-modal="false">
      <span slot="title" class="dialog-title">修改</span>
      <div class="dialogOtherinfo">
        <div v-if="nameName == '产品名'" style="padding:0px 0px 10px 10px;">
          <div style="display: inline-block;margin-right: 50px;">检验编号：{{data11Info.checkoutNumber}}</div>
          <div style="display: inline-block;margin-right: 50px;">产品名：{{data11Info.productName}}</div>
          <div>工程名：{{data11Info.engineeringName}}</div>
        </div>
        <div v-else-if="nameName == '配合比'">
          <div style="display: inline-block;margin-right: 50px;">检验编号：{{data11Info.checkoutNumber}}</div>
          <div style="display: inline-block;margin-right: 50px;">原物料名称：{{data11Info.rawName}}</div>
          <div style="padding:5px;">供应商：
            <el-input v-model="data11Info.supplierName" style="width:215px;margin-left:25px;" placeholder="请输入"></el-input>
          </div>
        </div>
        <el-form v-if="name == '出场'" label-width="90px">
          <el-form-item label="构件尺寸：">
            <el-select v-model="data11Info.sizeValue" placeholder="请选择">
              <el-option label="100mm*100mm*100mm" value="100mm*100mm*100mm"></el-option>
              <el-option label="150mm*150mm*150mm" value="150mm*150mm*150mm"></el-option>
            </el-select>
          </el-form-item>
        </el-form>
        <el-form label-width="90px" style="display: flex;">
          <el-form-item label="取样时间" prop="startTime">
            <el-date-picker v-model="data11Info.samplingDate" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择日期时间"></el-date-picker>
          </el-form-item>
          <el-form-item label="检测人" prop="startTime" class="FZYplaceholder">
            <!-- <el-input v-model="data11Info.inspector" style="width:215px;margin-left:25px;" placeholder="请输入"></el-input> -->
            <TreeSelect ref="inspectorName" v-model="data11Info.inspectorId0" :loadData="onLoadData" :placeholder="inspectorName" style="width: 200px;height:36px;z-index:100000;" :tree-data="treeData" allowClear :replaceFields="{title:'name',value:'id'}" :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }" treeNodeFilterProp="title" @change="data11Info.inspectorId=data11Info.inspectorId0,$nextTick(() => {data11Info.inspector=$refs.inspectorName.$el.innerText})" @click="TreeSelectStypeFun()"></TreeSelect>
          </el-form-item>
        </el-form>
        <br>
        <el-table ref="singleTable" :header-cell-style="{ background: '#f3f6f9' }" :cell-style="{ borderRight: 'none' }" border stripe style="width:100%" :data="table11Modify" tooltip-effect="dark" highlight-current-row>
          <el-table-column prop="acceptanceItems" label="验收项目" width="auto" align="center"></el-table-column>
          <el-table-column prop="technicalRequirements" label="技术要求" width="260" align="center">
            <template slot-scope="scope">
              <div v-if="scope.row.resultValueType == 3">
                {{scope.row.technicalRequirements+'：'+(scope.row.section?scope.row.section:'')}}
              </div>
              <div v-else>
                {{scope.row.section?scope.row.section:''}}
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="lowerLimitVlue" label="下限值" width="auto" align="center"></el-table-column>
          <el-table-column prop="upperLimitVlue" label="上限值" width="auto" align="center"></el-table-column>
          <el-table-column label="结果值" width="auto" align="center">
            <template slot-scope="scope">
              <div v-if="scope.row.resultValueType == 3">
                <el-input v-model="scope.row.resultValue" style="width:100%" @input="checkOkNgFun(scope.row.resultValue,scope.row.technicalRequirements,scope.row.section,scope.row)"></el-input>
              </div>
              <div v-else>
                {{scope.row.resultValue}}
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="resultJudge" label="结果判断" width="auto" align="center">
            <template slot-scope="scope">
              <span v-if="scope.row.resultJudge == 'OK'" style="color:#4D906F;">OK</span>
              <span v-if="scope.row.resultJudge == 'NG'" style="color:red;">NG</span>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button class="bottom_all_two" @click="look11ModifyType = false">取 消</el-button>
        <el-button class="bottom_all" style="margin-left: 24px;" @click="selfdetectionupdateManyFun()">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import {
  saveOneProduct,
  selfreportqueryPage,
  selfreportupdateOne,
  selfreportqueryChecked,
  selfreportdelectMany,
  selfdetectionqueryByReportId,
  selfdetectionupdateMany,
  planSelfsaveMany,
  //以上是产品的接口
  disclosequeryOne,
  discloseupdateOne,
  workMixRatioqueryListByGeneral,
  workMixRatiogetRatioDetail,
  dataMixqueryPlan,
  dataMixgetRatioDetail,
  dataMixsaveOrUpdate,
  dataMixgetByPlan,
  queryEngineeringList,
  //以上是配合比的接口
  makequeryByRaw,
  rawgetPageByRaw,
  selfreportqueryPageRaw,
  saveOneRaw,
} from "@/api/smart/produceCoordinate.js";
import { getDicType, getFileDetails, getOrgznizationAndUsersTree, getPermissionsUserTree } from "@/api/common.js";
import { Loading } from 'element-ui';
import { getToken, getUserId } from '@/utils/auth';
import { getUserInfo } from "@/utils/auth.js";
let loadingInstance;
import { TreeSelect } from 'ant-design-vue';
export default {
  components: { TreeSelect },
  props: ['status'],
  data() {
    return {
      inspectorName: "",
      treeData: [],
      upheader: {
        "access-token": getToken(),
        "user-id": getUserId(),
      },
      scopeIndex: '',//1厂家材质报告，2合格证书
      rowIndex: '',//第几行的
      materialReportFileCheck: {},//厂家材质报告校验
      qualificationFileCheck: {}, //合格证书校验
      addType1: false,
      look1Type: false,
      look2Type: false,
      look11Type: false,
      look21Type: false,
      look11ModifyType: false,
      data11Info: { sizeValue: '', inspectorId: '' },//修改的信息
      table11Modify: [],//修改原物料list
      table2: [],
      table3: [],
      engineeringIdList: [],
      arr3_3: [],
      arr3_4: [],
      arr3_5: [],
      tableParam3: {//配合比-历史配合比列表分页
        page: 1,
        pageSize: 5,
        total: 0,
        engineeringId: '',
        dataType: this.status
      },
      tableParam11: { page: 1, pageSize: 10000, total: 0 },//产品分页1
      tableParam12: { page: 1, pageSize: 5, total: 0 },//产品分页2
      tableParam13: { page: 1, pageSize: 5, total: 0 },//产品分页3
      tableParam21: { page: 1, pageSize: 5, total: 0 },//配合比分页1
      tableParam22: { page: 1, pageSize: 5, total: 0 },//配合比分页2
      tableParam23: { page: 1, pageSize: 5, total: 0 },//配合比分页3
      table11: [],
      table12: [],
      table13: [],
      table21: [],
      table22: [],
      table23: [],
      fromDate: { enginnerrMixRatio: '', cementBrandId: '', openingProjecName: '' },
      yiFenPeiRadio: '',
      toViewList: [],
      plan: {},//strengthGradeId是强度等级id,engineeringId是工程id
      table21ModifyName: '',//修改原物料供应商名称
      selectionChange11List: [],//自检报告库多选选中的
      selectionChange21radio: '',//自检报告库单选选中的
      rawIdArry: [],//获取基础配置的原物料列表
      specificationIdArry: [],//规格型号
      formulaParametersIdArry: [
        {
          id: '1',
          name: '水'
        },
        {
          id: '2',
          name: '水泥',
          type: true
        },
        {
          id: '3',
          name: '细骨料'
        },
        {
          id: '4',
          name: '掺合料'
        },
        {
          id: '5',
          name: '外加剂'
        },
        {
          id: '6',
          name: '纤维'
        },
        {
          id: '7',
          name: '粗骨料'
        },
      ],
      list0Row: {},
      list0RowIndex: '',
      name: '',//出场、第三方
      name2: '',//批次检验、第三方检验
      nameName: '',//产品名，配合比
      fromDate3: {},//新增报告
      addType: true,//
      mixRatioNumberType: false,//未配置时可以改配合比编号
    };
  },
  async created() {
    /*获取基础配置的原物料列表*/
    getDicType({ code: "MATname" }).then((res) => {
      this.rawIdArry = res.data.items.map((v) => {
        return {
          id: v.id,
          name: v.itemName
        }
      });
    });
    /**规格型号 */
    getDicType({ code: "MATspec" }).then((res) => {
      this.specificationIdArry = res.data.items;
    });
    /**原物料品牌 */
    getDicType({
      code: "MATbrand",
    }).then((res) => {
      this.arr3_3 = res.data.items;
    });
    /*工程列表下拉*/
    queryEngineeringList().then((res) => {
      this.engineeringIdList = res.data
    })
    //厂家材质报告
    getFileDetails({ code: 'certificateOfApproval' }).then(res => {
      if (res.code === 1001) {
        console.log(res.data, 'certificateOfApproval')
        this.materialReportFileCheck = res.data;
      }
    })
    //合格证书
    getFileDetails({ code: 'manufacturerMaterialReport' }).then(res => {
      if (res.code === 1001) {
        console.log(res.data, 'manufacturerMaterialReport')
        this.qualificationFileCheck = res.data;
      }
    })
    this.treeData = await getPermissionsUserTree()
  },
  methods: {
    /**上传前的验证 */
    beforeUpload(file) {
      console.log(this.scopeIndex, this.rowIndex);
      if (this.scopeIndex == 1) {
        if (!this.materialReportFileCheck || !this.materialReportFileCheck ?.fileType) {
          this.$message.error('当前流程未配置附件，请配置后再进行上传');
          return false;
        }
        const fileType = file.name.split('.')[1];
        const isTYPE = this.materialReportFileCheck.fileType.indexOf(fileType) > -1;
        const isLtM = file.size / 1024 / 1024 < this.materialReportFileCheck.trillionSize;
        if (!isTYPE) {
          this.$message.error('图片格式只能为' + this.materialReportFileCheck.fileType);
          return false;
        }
        if (!isLtM) {
          this.$message.error(`图片大小不能超过${this.materialReportFileCheck.trillionSize}M`);
          return false;
        }
      } else if (this.scopeIndex == 2) {
        if (!this.qualificationFileCheck || !this.qualificationFileCheck ?.fileType) {
          this.$message.error('当前流程未配置附件，请配置后再进行上传');
          return false;
        }
        const fileType = file.name.split('.')[1];
        const isTYPE = this.qualificationFileCheck.fileType.indexOf(fileType) > -1;
        const isLtM = file.size / 1024 / 1024 < this.qualificationFileCheck.trillionSize;
        if (!isTYPE) {
          this.$message.error('图片格式只能为' + this.qualificationFileCheck.fileType);
          return false;
        }
        if (!isLtM) {
          this.$message.error(`图片大小不能超过${this.qualificationFileCheck.trillionSize}M`);
          return false;
        }
      }
      loadingInstance = Loading.service({ text: '上传中...' });
      return true;
    },
    /**上传成功后的赋值 */
    filesuccess(res) {
      console.log(res.data);
      if (res.code === 1001) {
        if (this.scopeIndex == 1) {
          this.toViewList[this.rowIndex].materialReport = res.data.fileName
          this.toViewList[this.rowIndex].materialReportPath = res.data.fileUrl
          loadingInstance.close();
        } else if (this.scopeIndex == 2) {
          this.toViewList[this.rowIndex].qualification = res.data.fileName
          this.toViewList[this.rowIndex].qualificationPath = res.data.fileUrl
          loadingInstance.close();

        }
      }
    },
    /**自检报告-确定按钮 */
    addListlist0Fun() {
      if (this.selectionChange21radio != '') {
        let e = this.table21.find((res) => res.id == this.selectionChange21radio)
        if (this.name2 == '批次检验') {
          this.toViewList[this.list0RowIndex].selfBatchId = e.id
          this.toViewList[this.list0RowIndex].selfBarchNum = e.checkoutNumber
          this.toViewList[this.list0RowIndex].rawBrand = e.brand
        } else if (this.name2 == '第三方检验') {
          this.toViewList[this.list0RowIndex].selfRipartiteId = e.id
          this.toViewList[this.list0RowIndex].selfRipartiteNum = e.checkoutNumber
          console.log(this.toViewList[this.list0RowIndex].selfRipartiteNum);
        }
        this.look21Type = false
      }
    },
    /**分页获取原物料列表(批次、第三方*/
    look21Fun(e, name, index) {
      this.list0Row = e
      this.list0RowIndex = index
      this.$data.tableParam21 = this.$options.data().tableParam21
      this.$data.tableParam22 = this.$options.data().tableParam22
      this.$data.tableParam23 = this.$options.data().tableParam23
      if (this.list0Row.rawId != '' && this.list0Row.specification != '') {
        this.look21Type = true
        this.name2 = name
        this.nameName = '配合比'
        this.table21 = []
        this.table22 = []
        this.table23 = []
        this.getmaintenancelist21(this.name2)
        this.getmaintenancelist22(this.name2)
        this.getmaintenancelist23(this.name2)
      } else {
        this.$message({
          message: '请选择原物料及规格',
          type: 'warning'
        });
      }
    },
    /**查询配合比选择中的第一个表格 */
    getmaintenancelist21(name) {
      this.tableParam21.rawId = this.list0Row.rawId
      this.tableParam21.planId = this.plan.id
      this.tableParam21.strengthGradeId = this.plan.strengthGradeId
      this.tableParam21.stationId = this.plan.stationId
      this.tableParam21.companyId = this.plan.companyId
      if (name == '批次检验') {
        this.tableParam21.checkoutType = 3
      } else if (name == '第三方检验') {
        this.tableParam21.checkoutType = 4
      }
      selfreportqueryPageRaw(this.tableParam21).then((res) => {
        this.tableParam21.total = res.data.totalRows
        this.table21 = res.data.data
        /**选中的打钩 */
        let selectArr = this.table21.filter((res) => res.checkStatus == 1)
        if (selectArr.length > 0) {
          this.selectionChange21radio = selectArr[0].id
        }
      })
    },
    /**查询配合比选择中的第二个表格 */
    getmaintenancelist22(name) {
      this.tableParam22.rawId = this.list0Row.rawId
      if (name == '批次检验') {
        this.tableParam22.dataTypeId = 2
        this.tableParam22.dataStatus = 1
        this.tableParam22.stationId = this.plan.stationId
        this.tableParam22.specification = this.list0Row.specification
        makequeryByRaw(this.tableParam22).then((res) => {
          res.data.data.map((res) => res.checkoutNumber = res.code)
          this.table22 = res.data.data
        })
      } else if (name == '第三方检验') {
        this.tableParam22.companyId = this.plan.companyId
        rawgetPageByRaw(this.tableParam22).then((res) => {
          this.table22 = res.data.data
        })
      }
    },
    /**查询配合比选择中的第三个表格 */
    getmaintenancelist23(name) {
      this.tableParam23.rawId = this.list0Row.rawId
      if (name == '批次检验') {
        this.tableParam23.checkoutType = 3
        selfreportqueryPage(this.tableParam23).then((res) => {
          this.table23 = res.data.data
        })
      } else if (name == '第三方检验') {
        this.tableParam23.checkoutType = 4
        selfreportqueryPage(this.tableParam23).then((res) => {
          this.table23 = res.data.data
        })
      }
    },
    /**获取交工配合比详细配置 */
    workMixRatiogetRatioDetailFun() {
      workMixRatiogetRatioDetail({ id: this.fromDate.DetailId }).then((res) => {
        this.fromDate = { ...this.fromDate, ...res.data }
        this.toViewList = JSON.parse(JSON.stringify(this.fromDate.list))
      })
    },
    /** 返回交工配合比名称列表*/
    workMixRatioqueryListByGeneralFun() {
      this.arr3_5 = []
      let json = {
        companyId: this.plan.companyId,
        type: this.fromDate.type,
        id: this.plan.engineeringId
      }
      this.fromDate.DetailId = ''
      workMixRatioqueryListByGeneral(json).then((res) => {
        this.arr3_5 = res.data
      })
    },
    /**保存配合比 */
    discloseupdateOneFun() {
      this.$refs.reffromDate.validate((valid) => {
        if (valid) {
          if (this.toViewList.length == 0) {
            this.$message({
              message: '配合比参数列表不能为空！',
              type: 'warning'
            });
            return
          }
          /**修改订单配合比特殊要求和水泥品牌 */
          let cementBrandName = this.arr3_3.find((res) => res.id == this.fromDate.cementBrandId).itemName
          let json = {
            id: this.plan.engineeringId,//工程id
            enginnerrMixRatio: this.fromDate.enginnerrMixRatio,//工程配合比特殊要求
            cementBrandId: this.fromDate.cementBrandId, // 水泥原物料品牌id
            openingProjecName: this.fromDate.openingProjecName,
            cementBrandName: cementBrandName//水泥原物料品牌
          }
          discloseupdateOne(json).then((res) => {
            if (res.code == 1001) {
              let type = true
              this.toViewList.forEach((v) => {
                if (v.formulaParametersId != 1 && v.ratioValue != 0) {
                  if (!v.selfBatchId || !v.specificationId) {
                    type = false
                  }
                }
              })
              if (type) {
                this.fromDate.planId = this.plan.id
                if (this.addType) {
                  this.toViewList.map((res) => {
                    res.type = 1
                  })
                } else {
                  //toViewList数据对比开始
                  let update = this.toViewList.filter((res) =>
                    this.fromDate.list.some((item) => res.id == item.id)
                  );
                  update.forEach((res) => {
                    res.type = 2;//修改的
                  });
                  let deleteData = this.fromDate.list.filter(
                    (res) => !update.some((item) => res.id == item.id)
                  );
                  deleteData.forEach((res) => {
                    res.type = 3; //3是删除
                  });
                  let addData = this.toViewList.filter(
                    //新增的type默认写死为 1
                    (res) => !update.some((item) => res.id == item.id)
                  );
                  this.toViewList = [...update, ...deleteData, ...addData];
                }
                //toViewList数据对比结束
                this.fromDate.list = JSON.parse(JSON.stringify(this.toViewList))
                this.fromDate.engineeringId = this.plan.engineeringId
                this.fromDate.dataType = this.status
                dataMixsaveOrUpdate(this.fromDate).then((res) => {
                  if (res.code == 1001) {
                    this.look2Type = false
                    this.$message({
                      message: '操作成功',
                      type: 'success'
                    });
                    this.$emit("reload");
                  }
                })
              } else {
                this.$message({
                  message: '请检查数据是否完整',
                  type: 'warning'
                });
              }
            }
          })
        } else {
          return false;
        }
      });
    },
    //配合比中的已配置列表单选选中
    currentChange3(currentRow) {
      if (currentRow) {
        this.yiFenPeiRadio = currentRow.id
        dataMixgetRatioDetail({ id: currentRow.id, dataType: this.status }).then((res) => {
          if (res.data) {
            this.fromDate = { ...this.fromDate, ...res.data }
            this.toViewList = JSON.parse(JSON.stringify(this.fromDate.list))
          } else {
            this.$message({
              message: '该订单没有配合比参数',
              type: 'warning'
            });
            setTimeout(() => {
              this.yiFenPeiRadio = ''
              this.$refs.singleTable.setCurrentRow();
            }, 2000)
          }
        })
      }
    },
    /**分页显示已分配配合比的订单列 */
    gettableData() {
      dataMixqueryPlan(this.tableParam3).then((res) => {
        this.tableParam3.total = res.data.totalRows
        this.table3 = res.data.data;
      });
    },
    /**点击配合比*/
    async look2Fun(e, type) {
      this.$data.fromDate = this.$options.data().fromDate
      this.mixRatioNumberType = type
      this.addType = true
      this.plan = e
      this.look2Type = true
      this.toViewList = []
      /**获取订单配合比特殊要求和水泥品牌 */
      await disclosequeryOne({ id: e.engineeringId, planId: this.plan.id }).then((res) => {
        if (res.data) {
          this.fromDate.enginnerrMixRatio = res.data.enginnerrMixRatio
          this.fromDate.cementBrandId = res.data.cementBrandId
          this.fromDate.openingProjecName = res.data.openingProjecName || e.engineeringName
        }
      })
      this.tableParam3.engineeringId = e.engineeringId
      this.gettableData()
      /**打开配置比显示默认数据 */
      await dataMixgetByPlan({ planId: e.id, engineeringId: e.engineeringId, dataType: this.status }).then((res) => {
        if (res.data) {
          this.addType = false
          this.fromDate = { ...this.fromDate, ...res.data }
          this.toViewList = res.data.list
          this.toViewList.map((res) => {
            res.type = 2
          })
        } else {
          this.initFormData()
        }
        this.fromDate.mixRatioNumber = e.mixRatioNumber
      })
    },
    /** 添加时初始列表 */
    initFormData() {
      this.toViewList = []
      function data(a, b, c, d) {
        this.type = 1  //1新增，2修改，3删除
        this.rawName = ""//物料名称
        this.rawId = ""//物料id
        this.specification = ""//规格
        this.specificationId = ""//规格id
        this.ratioValue = 0 //配合比值
        this.list = []
        this.formulaParameters = a//公式参数类型
        this.formulaParametersId = b  //1水、2水泥、3细骨料、4掺合料、5外加剂、6纤维
        this.parametersType = c//参数类型
        this.parameter = d  //参量

      }
      this.toViewList.push(new data('水', '1', "水", 100))
      this.toViewList.push(new data('水泥', '2', "水泥", 100))
      this.toViewList.push(new data('细骨料', '3', "细骨料", 100))
      this.toViewList.push(new data('外加剂', '5', "外加剂", 0))
    },
    /**修改页面——保存检验结果（三方和出场 */
    selfdetectionupdateManyFun() {
      if (this.name == '出场' && !this.data11Info.sizeValue) {
        this.$message({
          message: '请选择构件尺寸',
          type: 'warning'
        });
        return
      }
      let type = true
      this.table11Modify.forEach((v) => {
        if (v.resultJudge == 'NG') {
          type = false
        }
      })
      if (type) {
        this.nameNameFun()
      } else {
        this.$confirm('是否保存', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          cancelButtonClass: 'bottom_all_two',
        confirmButtonClass: 'bottom_all',
          type: 'warning'
        }).then(() => {
          this.nameNameFun()
        })
      }
    },
    /**修改页面——保存检验结果（三方和出场 */
    nameNameFun() {
      console.log(this.nameName);
      const params = {
        selfResport: {
          id: this.data11Info.id,
          supplierName: this.data11Info.supplierName,
          inspector: this.data11Info.inspector,
          inspectorId: this.data11Info.inspectorId,
          samplingDate: this.data11Info.samplingDate,
          sizeId: this.data11Info.sizeValue === '100mm*100mm*100mm' ? 1 : 2,
          sizeValue: this.data11Info.sizeValue,
        },
        list: this.table11Modify,
      }
      selfdetectionupdateMany(params).then((res) => {
        if (res.code == 1001) {
          this.look11ModifyType = false
          this.$message.success('保存成功');
        }
      })
    },
    //多选选中
    selectionChange11(val) {
      this.selectionChange11List = val
    },
    /**产品名-自检报告-保存 */
    planSelfsaveManyFun() {
      let arr = []
      this.selectionChange11List.forEach((v) => {
        arr.push({ selfReportId: v.id })
      })
      let json = {
        planId: this.plan.id,
        checkoutType: '',// 1出场检测 2三方检测,5抗渗报告
        list: arr,
        dataType: this.status,// 1交工配置 2 交工资料
      }
      if (this.name == '出场') {
        json.checkoutType = 1
      } else if (this.name == '抗渗报告') {
        json.checkoutType = 5
      } else if (this.name == '第三方') {
        json.checkoutType = 2
      }
      // console.log(JSON.parse(JSON.stringify(json)))
      planSelfsaveMany(json).then((res) => {
        if (res.code == 1001) {
          this.look11Type = false;
          this.$emit("reload");
        }
      })
    },
    /**新增报告 */
    selfreportsaveOneFun() {
      console.log(this.plan);
      //产品名和公用参数赋值
      this.fromDate3.strengthGradeId = this.plan.strengthGradeId
      this.fromDate3.organizationId = this.plan.organizationId
      this.fromDate3.stationName = this.plan.stationName
      this.fromDate3.stationId = this.plan.stationId
      this.fromDate3.companyId = this.plan.companyId
      this.fromDate3.company = this.plan.company
      this.fromDate3.productName = this.plan.productName
      this.fromDate3.engineeringName = this.plan.engineeringName
      this.fromDate3.engineeringId = this.plan.engineeringId
      this.fromDate3.type = 2
      if (this.name == '出场') {
        this.fromDate3.checkoutType = 1
      } else if (this.name == '抗渗报告') {
        this.fromDate3.checkoutType = 5
      }
      saveOneProduct(this.fromDate3).then(res => {
        if (res.code == 1001) {
          this.addType1 = false
          this.getmaintenancelist11()
        }
      })
    },
    /**删除产品名的自检报告库 */
    delTable11Fun(e) {
      this.$confirm('此操作将删除本条数据, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        cancelButtonClass: 'bottom_all_two',
        confirmButtonClass: 'bottom_all',
        type: 'warning'
      }).then(() => {
        selfreportdelectMany({ id: e.id }).then((res) => {
          if (res.code == 1001) {
            this.getmaintenancelist11(this.name)
            this.$message({
              type: 'success',
              message: '删除成功!'
            });
          }
        })
      })
    },
    /**删除配合比的自检报告库 */
    delTable21Fun(e) {
      this.$confirm('此操作将删除本条数据, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        cancelButtonClass: 'bottom_all_two',
        confirmButtonClass: 'bottom_all',
        type: 'warning'
      }).then(() => {
        selfreportdelectMany({ id: e.id }).then((res) => {
          if (res.code == 1001) {
            this.getmaintenancelist21(this.name2)
            this.getmaintenancelist22(this.name2)
            this.$message({
              type: 'success',
              message: '删除成功!'
            });
          }
        })
      })
    },
    /**自检报告库点开修改 */
    modifyLookFun(e) {
      this.look11ModifyType = true
      this.data11Info = e
      this.inspectorName = e.inspector;
      this.table11Modify = []
      selfdetectionqueryByReportId({ selfReportId: e.id }).then((res) => {
        this.table11Modify = res.data.list
        this.data11Info.sizeValue = res.data.selfResport.sizeValue
        if (!this.data11Info.inspector) {
          this.data11Info.inspector = getUserInfo().userRealName
        }
      })
    },
    /*配合比-添加入库/复制到库（三方和出场）*/
    addtable21(e, name) {
      console.log(e);
      if (name == '原物料') {
        let json = {
          organizationId: this.plan.organizationId,
          stationName: this.plan.stationName,
          stationId: this.plan.stationId,
          companyId: this.plan.companyId,
          company: this.plan.company,
          supplierName: e.supplierName,
          rawName: e.rawName,
          brand: e.brand,
          dataSourcesId: e.id,
          type: 1,
          inspector: e.detection,
          inspectorId: e.inspectorId,
          samplingDate: e.detectionTime
        }
        if (this.name2 == '批次检验') {
          json.checkoutType = 3
          json.rawId = e.rawNameId
          json.checkoutNumber = e.checkoutNumber
          json.rawMaterialsId = e.rawId
        } else if (this.name2 == '第三方检验') {
          json.checkoutType = 4
          json.rawId = e.rawId
          json.checkoutNumber = e.code
        }
        saveOneRaw(json).then((res) => {
          if (res.code == 1001) {
            this.getmaintenancelist21()
            this.getmaintenancelist22(this.name2)
            this.getmaintenancelist23(this.name2)
          }
        })
      } else if (name == '已过期') {
        selfreportupdateOne({ "id": e.id }).then((res) => {
          if (res.code == 1001) {
            this.getmaintenancelist21()
            this.getmaintenancelist22()
            this.getmaintenancelist23()
          }
        })
      }
    },
    /**产品名-分页获取混凝土列表(三方和出场)*/
    look11Fun(e, name) {
      this.$data.tableParam11 = this.$options.data().tableParam11
      this.$data.tableParam12 = this.$options.data().tableParam12
      this.$data.tableParam13 = this.$options.data().tableParam13
      this.name = name
      this.nameName = '产品名'
      this.look11Type = true
      this.plan = e
      this.table11 = []
      this.table12 = []
      this.table13 = []
      if (this.name == '出场' || this.name == '抗渗报告') {
        this.getmaintenancelist11(this.name)
      } else {
        this.getmaintenancelist11(this.name)
      }
    },
    /*产品名-分页获取自检报告（三方和出场*/
    getmaintenancelist11() {
      this.tableParam11.status = this.status// 数据类型 1交工配置 2 交工资料
      this.tableParam11.planId = this.plan.id
      this.tableParam11.strengthGradeId = this.plan.strengthGradeId
      if (this.name == '出场') {
        this.tableParam11.stationId = this.plan.stationId
        this.tableParam11.engineeringId = this.plan.engineeringId
        this.tableParam11.checkoutType = 1
      } else if (this.name == '抗渗报告') {
        this.tableParam11.stationId = this.plan.stationId
        this.tableParam11.engineeringId = this.plan.engineeringId
        this.tableParam11.checkoutType = 5
      } else if (this.name == '第三方') {
        this.tableParam11.companyId = this.plan.companyId
        this.tableParam11.checkoutType = 2
      }
      selfreportqueryChecked(this.tableParam11).then((res) => {
        this.tableParam11.total = res.data.totalRows
        this.table11 = res.data.data
        /**选中的打钩 */
        let selectArr = this.table11.filter((res) => res.checkStatus == 1)
        selectArr.forEach((v) => {
          this.$nextTick(() => {
            this.$refs.table11Refs.toggleRowSelection(v);
          });
          let type = this.selectionChange11List.findIndex((v2) => {
            return v.id == v2.id
          })
          if (type == -1) {
            this.selectionChange11List.push(v)
          }
        })
      })
    },
    //单选选中
    selectionChange21radioFun(currentRow) {
      if (currentRow) {
        this.selectionChange21radio = currentRow.id
      }
    },
    /**点击产品名 */
    look1Fun(e) {
      this.look1Type = true
      this.table2 = [e]
    },
    /**验证OK还是NG */
    checkOkNgFun(val, technicalRequirements, section, row) {
      console.log(val, technicalRequirements, section);
      if (technicalRequirements == '≥') {
        if (Number(val) >= Number(section)) {
          row.resultJudge = 'OK'
          return 'OK'
        } else {
          row.resultJudge = 'NG'
          return 'NG'
        }
      } else if (technicalRequirements == '＞') {
        if (Number(val) > Number(section)) {
          row.resultJudge = 'OK'
          return 'OK'
        } else {
          row.resultJudge = 'NG'
          return 'NG'
        }
      } else if (technicalRequirements == '≤') {
        if (Number(val) <= Number(section)) {
          row.resultJudge = 'OK'
          return 'OK'
        } else {
          row.resultJudge = 'NG'
          return 'NG'
        }
      } else if (technicalRequirements == '＜') {
        if (Number(val) < Number(section)) {
          row.resultJudge = 'OK'
          return 'OK'
        } else {
          row.resultJudge = 'NG'
          return 'NG'
        }
      } else if (technicalRequirements == '=') {
        if (Number(val) == Number(section)) {
          row.resultJudge = 'OK'
          return 'OK'
        } else {
          row.resultJudge = 'NG'
          return 'NG'
        }
      } else if (technicalRequirements == '≤x,且x≤') {
        if (Number(val) >= Number(row.section.split(',')[0]) && Number(val) <= Number(row.section.split(',')[1])) {
          row.resultJudge = 'OK'
          return 'OK'
        } else {
          row.resultJudge = 'NG'
          return 'NG'
        }
      } else if (technicalRequirements == '<x,且x<') {
        if (Number(val) > Number(row.section.split(',')[0]) && Number(val) < Number(row.section.split(',')[1])) {
          row.resultJudge = 'OK'
          return 'OK'
        } else {
          row.resultJudge = 'NG'
          return 'NG'
        }
      } else if (technicalRequirements == '≤x,且x<') {
        if (Number(val) >= Number(row.section.split(',')[0]) && Number(val) < Number(row.section.split(',')[1])) {
          row.resultJudge = 'OK'
          return 'OK'
        } else {
          row.resultJudge = 'NG'
          return 'NG'
        }
      } else if (technicalRequirements == '<x,且x≤') {
        if (Number(val) > Number(row.section.split(',')[0]) && Number(val) <= Number(row.section.split(',')[1])) {
          row.resultJudge = 'OK'
          return 'OK'
        } else {
          row.resultJudge = 'NG'
          return 'NG'
        }
      } else if (technicalRequirements == 'x≤,或x≥') {
        if (Number(val) <= Number(row.section.split(',')[0]) || Number(val) >= Number(row.section.split(',')[1])) {
          console.log('OK');
          row.resultJudge = 'OK'
          return 'OK'
        } else {
          console.log('NG');
          row.resultJudge = 'NG'
          return 'NG'
        }
      } else if (technicalRequirements == 'x<或x>') {
        if (Number(val) < Number(row.section.split(',')[0]) || Number(val) > Number(row.section.split(',')[1])) {
          row.resultJudge = 'OK'
          return 'OK'
        } else {
          row.resultJudge = 'NG'
          return 'NG'
        }
      } else if (technicalRequirements == '≤x,或x<') {
        if (Number(val) >= Number(row.section.split(',')[0]) || Number(val) < Number(row.section.split(',')[1])) {
          row.resultJudge = 'OK'
          return 'OK'
        } else {
          row.resultJudge = 'NG'
          return 'NG'
        }
      } else if (technicalRequirements == '<x,或x≤') {
        if (Number(val) > Number(row.section.split(',')[0]) || Number(val) <= Number(row.section.split(',')[1])) {
          row.resultJudge = 'OK'
          return 'OK'
        } else {
          row.resultJudge = 'NG'
          return 'NG'
        }
      }
    },
    /**前4个不能操作的改色--------下面都是配合比中的表格 */
    tableRowClassName({ rowIndex }) {
      if (rowIndex < 4) {
        return 'ccc';
      }
    },
    /**赋值name名 */
    changeItem(e, name) {
      if (name == 'rawId') {
        e.rawName = this.$fromatTable(
          this.rawIdArry,
          e.rawId,
          "id",
          "name"
        );
      } else if (name == 'specificationId') {
        e.specification = this.$fromatTable(
          this.specificationIdArry,
          e.specificationId,
          "id",
          "itemName"
        );
      } else if (name == 'formulaParametersId') {
        e.formulaParameters = this.$fromatTable(
          this.formulaParametersIdArry,
          e.formulaParametersId,
          "id",
          "name"
        );
        this.parametersTypeFun()
        this.calculatorFun()
      }
    },
    /*表单增加*/
    addItem() {
      let data = {
        type: 1,  //1新增，2修改，3删除
        rawName: "",//物料名称
        rawId: "",//物料id
        specification: "",//规格
        specificationId: "",//规格id
        formulaParameters: "",//公式参数类型
        formulaParametersId: '',  //1水、2水泥、3细骨料、4掺合料、5外加剂、6纤维
        parametersType: "",//参数类型
        parameter: 0,  //参量
        ratioValue: 0,     //配合比值
        list: []
      }
      this.toViewList.push(data);
    },
    /*表单删除*/
    deleteItem(index) {
      this.toViewList.splice(index, 1);
      this.parametersTypeFun()
      this.calculatorFun()
    },
    /** 算值配合比值,同时验证参数是否完整 */
    calculatorFun(type) {
      if (!this.fromDate.unitWeight || !this.fromDate.totalPlasticMaterial || !this.fromDate.waterBinderRatio || !this.fromDate.sandRatio) {
        if (!type) {
          this.$message({
            message: '请填写容重、胶材总量、水胶比、砂率',
            type: 'warning'
          });
        }
        // if (index > 2) {
        //   setTimeout(() => {
        //     e.parameter = 0
        //   }, 10)
        // } else {
        //   setTimeout(() => {
        //     e.parameter = 100
        //   }, 10)
        // }
      } else {
        /** 所有水的配合比值和 */
        let waterAll = 0
        /** 所有水泥的配合比值和 */
        let cementAll = 0
        /** 所有掺合料的配合比值和 */
        let admixtureAll = 0
        /** 所有掺合料的参量和 */
        let admixtureParameterAll = 0
        /** 所有外加剂的配合比值和 */
        let additiveAll = 0
        /** 所有细骨料的配合比值和 */
        let slenderAll = 0
        //按调用参数顺序先算4，5，再算1，再算2，再算3，再算7【6跟谁都无关最后算】!!!!!!!!!!!!!!!
        //4掺合量和5:外加剂：胶材总量*参量
        this.toViewList.forEach((v) => {
          if (v.formulaParametersId == 4 || v.formulaParametersId == 5) {
            if (v.formulaParametersId == 5) {
              v.ratioValue = (Number(this.fromDate.totalPlasticMaterial) * (v.parameter / 100)).toFixed(2)
            } else {
              v.ratioValue = (Number(this.fromDate.totalPlasticMaterial) * (v.parameter / 100)).toFixed(0)
            }
          }
        })
        this.toViewList.forEach((v) => {
          if (v.formulaParametersId == 4) {
            admixtureAll = admixtureAll + Number(v.ratioValue)
            admixtureParameterAll = admixtureParameterAll + Number(v.parameter / 100)
          }
          if (v.formulaParametersId == 5) {
            additiveAll = additiveAll + Number(v.ratioValue)
          }
        })
        //1水：胶材总量*水胶比-（所有外加剂的配合比值和 *0.9）*水N的参量
        this.toViewList.forEach((v) => {
          if (v.formulaParametersId == 1) {
            v.ratioValue = ((Number(this.fromDate.totalPlasticMaterial) * Number(this.fromDate.waterBinderRatio)) - (additiveAll * 0.9) * (v.parameter / 100)).toFixed(0)
          }
        })
        this.toViewList.forEach((v) => {
          if (v.formulaParametersId == 1) {
            waterAll = waterAll + Number(v.ratioValue)
          }
        })
        //2水泥：胶材总量*（1-所有掺合料参量的和）
        this.toViewList.forEach((v) => {
          if (v.formulaParametersId == 2) {
            v.ratioValue = (Number(this.fromDate.totalPlasticMaterial) * (1 - admixtureParameterAll)).toFixed(0)
          }
        })
        this.toViewList.forEach((v) => {
          if (v.formulaParametersId == 2) {
            cementAll = cementAll + Number(v.ratioValue)
          }
        })
        //3细骨料N：【容重-所有水的配合比值之和-所有水泥配合比值之和-所有掺合料的配合比值之和-所有外加剂的配合比值之和】*砂率*细骨料N的参量
        this.toViewList.forEach((v) => {
          if (v.formulaParametersId == 3) {
            v.ratioValue = ((Number(this.fromDate.unitWeight) - waterAll - cementAll - admixtureAll - additiveAll) * (Number(this.fromDate.sandRatio) / 100) * (v.parameter / 100)).toFixed(0)
          }
        })
        this.toViewList.forEach((v) => {
          if (v.formulaParametersId == 3) {
            slenderAll = slenderAll + Number(v.ratioValue)
          }
        })
        //6纤维：配合比值同参量值
        this.toViewList.forEach((v) => {
          if (v.formulaParametersId == 6) {
            v.ratioValue = v.parameter
          }
        })
        //7粗骨料N：[（所有细骨料的配合比值之和/砂率）-所有细骨料的配合比值之和]*粗骨料N参量
        this.toViewList.forEach((v) => {
          if (v.formulaParametersId == 7) {
            v.ratioValue = ((slenderAll / (Number(this.fromDate.sandRatio) / 100) - slenderAll) * (v.parameter / 100)).toFixed(0)
          }
        })
      }
    },
    /** 参数类型多个时追加拼接数字 */
    parametersTypeFun() {
      /** 公式参数类型：水的数量 */
      let waterSize = 0
      /** 公式参数类型：细骨料的数量 */
      let slenderSize = 0
      /** 公式参数类型：掺合料的数量 */
      let admixtureSize = 0
      /** 公式参数类型：外加剂的数量 */
      let additive = 0
      /** 公式参数类型：纤维的数量 */
      let fiberSize = 0
      /** 公式参数类型：粗骨料的数量 */
      let thickSize = 0
      this.toViewList.forEach((v) => {
        if (v.formulaParametersId == 1) {
          waterSize = waterSize + 1
        } else if (v.formulaParametersId == 3) {
          slenderSize = slenderSize + 1
        } else if (v.formulaParametersId == 4) {
          admixtureSize = admixtureSize + 1
        } else if (v.formulaParametersId == 5) {
          additive = additive + 1
        } else if (v.formulaParametersId == 6) {
          fiberSize = fiberSize + 1
        } else if (v.formulaParametersId == 7) {
          thickSize = thickSize + 1
        }
      })
      /** 拼接的数字 */
      let sizeText1 = 0, sizeText3 = 0, sizeText4 = 0, sizeText5 = 0, sizeText6 = 0, sizeText7 = 0;
      this.toViewList.forEach((v) => {
        if (v.formulaParametersId == 1) {
          if (waterSize > 1) {
            sizeText1 = sizeText1 + 1
            v.parametersType = v.formulaParameters + String(sizeText1)
          } else {
            v.parametersType = v.formulaParameters
          }
        } else if (v.formulaParametersId == 3) {
          if (slenderSize > 1) {
            sizeText3 = sizeText3 + 1
            v.parametersType = v.formulaParameters + String(sizeText3)
          } else {
            v.parametersType = v.formulaParameters
          }
        } else if (v.formulaParametersId == 4) {
          if (admixtureSize > 1) {
            sizeText4 = sizeText4 + 1
            v.parametersType = v.formulaParameters + String(sizeText4)
          } else {
            v.parametersType = v.formulaParameters
          }
        } else if (v.formulaParametersId == 5) {
          if (additive > 1) {
            sizeText5 = sizeText5 + 1
            v.parametersType = v.formulaParameters + String(sizeText5)
          } else {
            v.parametersType = v.formulaParameters
          }
        } else if (v.formulaParametersId == 6) {
          if (fiberSize > 1) {
            sizeText6 = sizeText6 + 1
            v.parametersType = v.formulaParameters + String(sizeText6)
          } else {
            v.parametersType = v.formulaParameters
          }
        } else if (v.formulaParametersId == 7) {
          if (thickSize > 1) {
            sizeText7 = sizeText7 + 1
            v.parametersType = v.formulaParameters + String(sizeText7)
          } else {
            v.parametersType = v.formulaParameters
          }
        }
      })
    },
    TreeSelectStypeFun() {
      if (this.TreeSelectStypeNumber === 0) {
        this.TreeSelectStypeNumber = 1;
        setTimeout(() => {
          const dom = document.body.lastChild;
          dom.style.zIndex = '10000'
        }, 1000)
      }
    },
    onLoadData(treeNode) {
      return new Promise((resolve) => {
        if (treeNode.dataRef.children) { // 有值了直接渲染
          resolve()
          return
        }
        /**获取自己公司加权限组织树带人员的 */
        // 没有值根据当前父节点获取下面子节点并挂在树节点中，添加到对应父节点的children中
        getOrgznizationAndUsersTree(treeNode.dataRef.id).then(res => {
          let children = res.data[0].children
          this.diGui(children)
          treeNode.dataRef.children = children
          this.$forceUpdate()
          console.log(JSON.parse(JSON.stringify(this.treeData)))
        })
        resolve()
      })
    },
    //递归判断是否是子节点
    diGui(arr) {
      if (arr.length > 0) {
        arr.forEach((res) => {
          if (res.children > 0) {
            this.diGui(res.children)
          } else {
            delete res.children
            if (res.selectable == true) {
              res.isLeaf = true
            }
          }
        })
      }
    }
  },
  filters: {
    filtFormula(index) {
      if (index > 3) {
        return false
      } else {
        return true
      }
    },
    precision(e) {
      if (e.formulaParametersId == 4) {
        return 1
      } else if (e.formulaParametersId == 5) {
        return 2
      } else {
        return 0
      }
    },
    filtDel(index) {
      if (index > 3) {
        return true
      } else {
        return false
      }
    },
  }
};
</script>

<style lang="scss" scoped>
.table_link {
  margin: 0 10px;
  color: $bg_color;
  cursor: pointer;
}

.table_link:hover {
  opacity: 0.8;
}
.el-link.el-link--default.is-disabled {
  cursor: not-allowed;
  display: flex;
}
</style>
